package com.bdqn.tour.dao.impl;

import com.bdqn.tour.dao.BaseDao;
import com.bdqn.tour.dao.HqfupdateScenicDao;
import com.bdqn.tour.pojo.Scenic;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

//修改景点信息
public class HqfupdateScenicImpl extends BaseDao implements HqfupdateScenicDao {
    @Override
    public int updateScenic(Scenic scenic) {
        int row = 0;
        //获取连接Connection
        Connection conn = this.getConnection();
        //初始化PreparedStatement
        PreparedStatement psmt = null;
        //编写sql语句 更新scenictable数据
        String sql = "update scenictable set scenic_name=?,scenic_address=?,price=?,img=?,satisfaction=?,city=?,html=? where scenic_Id=?";
        try {
            //获取预编译对象
            psmt = conn.prepareStatement(sql);
            psmt.setString(1,scenic.getScenic_name());
            psmt.setString(2,scenic.getScenic_address());
            psmt.setInt(3,scenic.getPrice());
            psmt.setString(4,scenic.getImg());
            psmt.setInt(5,scenic.getSatisfaction());
            psmt.setString(6,scenic.getCity());
            psmt.setString(7,scenic.getHtml());
            psmt.setInt(8,scenic.getScenic_Id());
            //执行sql语句
            row = psmt.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            closeAll(conn,psmt,null);
        }
        return row;
    }


}


